<html>
<head><meta charset="utf-8"><title>Try-trait wishlist, pre-meeting · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html">Try-trait wishlist, pre-meeting</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196016428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196016428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196016428">(May 01 2020 at 22:17)</a>:</h4>
<p>I wanted to start collecting goals and similar talking before next week's design meeting.  Here's a quick brainstorm:</p>
<p>Wishes:</p>
<ul>
<li><code>x?</code>'s type is predictable from <code>x</code>'s type; it's not context dependent.  (This is important for things like <code>x?.foo()</code> or <code>dbg!(x?);</code> that don't provide type guides.</li>
<li>Similar to the previous, the success value expected as the result of the inside of a <code>try{}</code> should be predictable from the resulting type, so things like <code>let x:Option&lt;usize&gt; = try { Default::default() };</code> don't give inference failures</li>
<li>The combination of <code>?</code> and <code>try</code> remembers its "resultness" or "optionness", so that the type of the try block doesn't need to be specified so often. (I think this is a change in goal from the RFC thread, so comments appreciated.)</li>
<li><code>try{}</code> blocks should be able to absorb many kinds of errors, if they want</li>
<li>Keeps the door open for some form of <code>yeet error</code> syntax in future -- should maybe decide whether this should have error-conversion support</li>
<li>Blocks using <code>option?</code> in a result-returning function and blocks using <code>result?</code> in an option-returning function.</li>
<li>Compatible with an elegant way to have extra context on errors.</li>
</ul>
<p>Non-wishes:</p>
<ul>
<li>Free intermixing of <code>Try</code> types with compatible errors (I think this is a change in goal from the RFC thread, so comments appreciated.)</li>
<li>Consistent <code>From</code> behaviour for all types as part of the <code>?</code> desugar (I think this is a change in goal from the RFC thread, so comments appreciated.)</li>
<li>Keep the vocabulary specifically about errors (I think this is a change in goal from the RFC thread, so comments appreciated.)</li>
</ul>
<p>Please reply with other things you come up with.  Let's try to keep to scoping and avoid solutioning in this topic for now, though.</p>



<a name="196018192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196018192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196018192">(May 01 2020 at 22:45)</a>:</h4>
<p>I'm in complete agreement with everything you've said in both lists.</p>



<a name="196018220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196018220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196018220">(May 01 2020 at 22:45)</a>:</h4>
<p>I definitely want to be able to write things like <code>let x = try { ... }.with_context(|| ...)?</code> without any extra type annotations.</p>



<a name="196018271"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196018271" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196018271">(May 01 2020 at 22:46)</a>:</h4>
<p>Or <code>let x = try { ... }; do_something(); x?</code></p>



<a name="196024051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196024051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196024051">(May 02 2020 at 00:29)</a>:</h4>
<p>More-difficult goals:</p>
<ul>
<li>Have <code>map</code> be a provided method on the trait, with the expected <code>x.map(f)</code> -&gt; <code>try{f(x?)}</code> implementation.  (This would, I think, require ATCs.)</li>
<li>Have at most negligible compile- and run-time overhead compared to hand-coding the <code>match</code>.</li>
<li>Support better-than-<code>From</code> error conversion without being blocked on specialization.</li>
</ul>



<a name="196024218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196024218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196024218">(May 02 2020 at 00:34)</a>:</h4>
<p>Future extensability:</p>
<ul>
<li>Be able to accomadate a potential future "none-/error-coalescing operator", like <code>x ☃ compute_fallback()</code>, which would help people naturally avoid the <a href="https://rust-lang.github.io/rust-clippy/master/#or_fun_call" title="https://rust-lang.github.io/rust-clippy/master/#or_fun_call">https://rust-lang.github.io/rust-clippy/master/#or_fun_call</a> gotcha (prior art: <code>??</code> in C#, and similar)</li>
</ul>



<a name="196025019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196025019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196025019">(May 02 2020 at 00:52)</a>:</h4>
<p>I've been using <code>Err(x)?</code> in my code to return an error and it works pretty well. If we do decide to add <code>yeet e</code> in the future, should it just be a shorthand for <code>Err(x)?</code> with the same error conversion semantics? I personally feel that adding new syntax for this is unnecessary since <code>Err(e)?</code> works just fine.</p>



<a name="196025053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196025053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196025053">(May 02 2020 at 00:53)</a>:</h4>
<p>That's one possible desugar. But that desugar would potentially necessitate a lot of type annotations.</p>



<a name="196025117"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196025117" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196025117">(May 02 2020 at 00:54)</a>:</h4>
<p>You wouldn't be able to capture the output of <code>try</code> and then use <code>?</code> on it again later, because inference wouldn't know what type to make the intermediate.</p>



<a name="196025134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196025134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196025134">(May 02 2020 at 00:55)</a>:</h4>
<p>I think it also only would work with <code>Result</code>.  I'm not sure what the correct syntax/semantics would be (assuming for now that it's needed) to return an error in code that's generic over the actual error carrier type</p>



<a name="196025210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196025210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196025210">(May 02 2020 at 00:57)</a>:</h4>
<p>In the simple case, <code>Err(e)?</code> is <code>return Err(From::from(e));</code>, and it's not obvious to me whether the <code>from</code> should be there if we added syntax.  It seems like one might rather than <code>yeet e;</code> is just <code>return Err(e);</code>, since you can always write <code>yeet e.into();</code> if you want.</p>



<a name="196025325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196025325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196025325">(May 02 2020 at 01:00)</a>:</h4>
<p>Oh, that reminds me:</p>
<p>Possible goal:</p>
<ul>
<li>Do <strong>not</strong> do error conversion in non-annotated <code>try</code> blocks, so that I don't have to redundantly specify the error type.</li>
</ul>



<a name="196025343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196025343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196025343">(May 02 2020 at 01:02)</a>:</h4>
<p>Note that <code>yeet e;</code> is not equivalent to anything involving <code>return</code>, because return bypasses a <code>try</code> block, but <code>yeet</code> doesn't.</p>



<a name="196025404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196025404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196025404">(May 02 2020 at 01:02)</a>:</h4>
<p>Yes, that's why I put "in the simple case".  <code>break 'nearest_try Err(e);</code>, if you prefer.</p>



<a name="196052416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196052416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> rpjohnst <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196052416">(May 02 2020 at 13:47)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125270">scottmcm</span> <a href="#narrow/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting/near/196024218" title="#narrow/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting/near/196024218">said</a>:</p>
<blockquote>
<p>Future extensability:</p>
<ul>
<li>Be able to accomadate a potential future "none-/error-coalescing operator", like <code>x ☃ compute_fallback()</code>, which would help people naturally avoid the <a href="https://rust-lang.github.io/rust-clippy/master/#or_fun_call" title="https://rust-lang.github.io/rust-clippy/master/#or_fun_call">https://rust-lang.github.io/rust-clippy/master/#or_fun_call</a> gotcha (prior art: <code>??</code> in C#, and similar)</li>
</ul>
</blockquote>
<p>For some context, the original RFC included <code>try { x? } catch e { compute_fallback() }</code> with exactly those semantics- the Ok-wrapping <code>try {}</code> version was originally specified as sugar for pass-through catches like <code>catch e { Err(e) }</code></p>



<a name="196059661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196059661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196059661">(May 02 2020 at 16:37)</a>:</h4>
<blockquote>
<ul>
<li>Consistent <code>From</code> behaviour for all types as part of the <code>?</code> desugar (I think this is a change in goal from the RFC thread, so comments appreciated.)</li>
</ul>
</blockquote>
<p><del>How would this interact with theoretical return traces? It seems like removing implicit from altogether in try blocks would basically torpedo that feature.</del></p>



<a name="196061593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196061593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jane Lusby <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196061593">(May 02 2020 at 17:24)</a>:</h4>
<p>Oh wait no, it's the try trait that matters, not the from, this is fine</p>



<a name="196178754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196178754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Malton <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196178754">(May 04 2020 at 13:21)</a>:</h4>
<p>Do we really want:</p>
<blockquote>
<ul>
<li>Blocks using <code>option?</code> in a result-returning function and blocks using <code>result?</code> in an option-returning function.</li>
</ul>
</blockquote>
<p>Wouldn't it be better to not allow this? Since <code>NoneError</code> (as we have currently) seems very cludgey and not very useful since it doesn't really point to where the non was.</p>



<a name="196182958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196182958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196182958">(May 04 2020 at 13:58)</a>:</h4>
<p>AFAIK this is possible on stable already... unfortunately.</p>



<a name="196185438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196185438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Malton <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196185438">(May 04 2020 at 14:14)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=a15c8ee2e8d9334aa95035d4b23e3c0a" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=a15c8ee2e8d9334aa95035d4b23e3c0a">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=a15c8ee2e8d9334aa95035d4b23e3c0a</a></p>
<p>This produces the error: <code>use of unstable library feature 'try_trait'</code>. So not actually on stable</p>



<a name="196201674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196201674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196201674">(May 04 2020 at 16:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="247082">Sebastian Malton</span> <a href="#narrow/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting/near/196178754" title="#narrow/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting/near/196178754">said</a>:</p>
<blockquote>
<p>Do we really want:</p>
<blockquote>
<ul>
<li>Blocks using <code>option?</code> in a result-returning function and blocks using <code>result?</code> in an option-returning function.</li>
</ul>
</blockquote>
<p>Wouldn't it be better to not allow this? Since <code>NoneError</code> (as we have currently) seems very cludgey and not very useful since it doesn't really point to where the non was.</p>
</blockquote>
<p>Oops, bad ambiguity on my part.  I meant "blocks" as a verb, not as a noun there.  I should have written "Prevent using ..."</p>



<a name="196202355"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196202355" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196202355">(May 04 2020 at 16:06)</a>:</h4>
<p>see <a class="stream-topic" data-stream-id="213817" href="/#narrow/stream/213817-t-lang/topic/Design.20meeting.3A.20try.2C.20oh.20my.21">#t-lang &gt; Design meeting: try, oh my!</a></p>



<a name="196202406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196202406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196202406">(May 04 2020 at 16:07)</a>:</h4>
<p><code>option?</code> to <code>Result</code> can be used on stable without naming <code>NoneError</code>:<br>
<a href="https://github.com/rust-lang/rust/issues/42327#issuecomment-469359526" title="https://github.com/rust-lang/rust/issues/42327#issuecomment-469359526">https://github.com/rust-lang/rust/issues/42327#issuecomment-469359526</a><br>
<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=bf6ef506f2e26fc9a77f7bad76eee8d2" title="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=bf6ef506f2e26fc9a77f7bad76eee8d2">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=bf6ef506f2e26fc9a77f7bad76eee8d2</a></p>



<a name="196203008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196203008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Malton <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196203008">(May 04 2020 at 16:11)</a>:</h4>
<p>Yes but that isn't using <code>NoneError</code> it is using a debug trait object.</p>



<a name="196203044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196203044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sebastian Malton <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196203044">(May 04 2020 at 16:11)</a>:</h4>
<p>Ah I see, well then we are in agreement</p>



<a name="196210955"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196210955" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196210955">(May 04 2020 at 17:08)</a>:</h4>
<p><span class="user-mention" data-user-id="138448">@cuviper</span> ah, thanks for the example. I'm sort of relieved to know that it's not just my <code>Poll</code> impls that cause this issue.</p>



<a name="196211097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196211097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196211097">(May 04 2020 at 17:10)</a>:</h4>
<p>I don't know if anyone does that in practice though, but I think it's plausible</p>



<a name="196211103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196211103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196211103">(May 04 2020 at 17:10)</a>:</h4>
<p>Based on that, I'd expect <code>let x: Result&lt;&amp;str, Error&gt; = try { Some(5)?; "foo" };</code> to work</p>



<a name="196211169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196211169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Taylor Cramer <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196211169">(May 04 2020 at 17:10)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> <span class="user-mention" data-user-id="239881">@Josh Triplett</span> ^</p>



<a name="196211323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/196211323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#196211323">(May 04 2020 at 17:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="127859">Taylor Cramer</span> <a href="#narrow/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting/near/196211103" title="#narrow/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting/near/196211103">said</a>:</p>
<blockquote>
<p>Based on that, I'd expect <code>let x: Result&lt;&amp;str, Error&gt; = try { Some(5)?; "foo" };</code> to work</p>
</blockquote>
<p>yep: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=e7f100dca6cb0bf4d1adf0968cb5a96f" title="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=e7f100dca6cb0bf4d1adf0968cb5a96f">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=e7f100dca6cb0bf4d1adf0968cb5a96f</a></p>



<a name="198071501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198071501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198071501">(May 19 2020 at 14:13)</a>:</h4>
<p>Hmm, that isn't what I expected by 'returning option? in function returning Result' - I have a lot of Option&lt;Result&gt; in my code and it would be great to have a way for the <code>Some</code> to get there automatically on error</p>



<a name="198095105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198095105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198095105">(May 19 2020 at 16:53)</a>:</h4>
<p>It seems to me that our ability to tweak the existing <code>Try</code> trait is just very limited</p>



<a name="198095129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198095129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198095129">(May 19 2020 at 16:53)</a>:</h4>
<p>I'm not sure how I feel about it but I guess I can live with it</p>



<a name="198095306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198095306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198095306">(May 19 2020 at 16:54)</a>:</h4>
<p>It's nice that it narrows the range of options at least :)</p>



<a name="198097209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198097209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198097209">(May 19 2020 at 17:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> What limits that? The <code>Try</code> trait itself (and thus any third-party impls) are not standard, right?</p>



<a name="198097249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198097249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198097249">(May 19 2020 at 17:06)</a>:</h4>
<p>We have to provide compatibility with the observable behavior of <code>?</code>; are there any other limitations?</p>



<a name="198098331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198098331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198098331">(May 19 2020 at 17:14)</a>:</h4>
<p>We also have to support the behavior of stable interfaces that use <code>Try</code>, namely <code>try_fold</code>, which means for example something like <code>Try::from_ok</code> is needed</p>



<a name="198098383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198098383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198098383">(May 19 2020 at 17:15)</a>:</h4>
<p>(but it doesn't have to be called that exactly)</p>



<a name="198098699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198098699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198098699">(May 19 2020 at 17:17)</a>:</h4>
<p>Ah, true.</p>



<a name="198133915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198133915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198133915">(May 19 2020 at 22:15)</a>:</h4>
<p><span class="user-mention" data-user-id="239881">@Josh Triplett</span> I mostly meant the observable behavior of <code>?</code></p>



<a name="198133942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Try-trait%20wishlist%2C%20pre-meeting/near/198133942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Try-trait.20wishlist.2C.20pre-meeting.html#198133942">(May 19 2020 at 22:15)</a>:</h4>
<p>but also e.g. the impls that <span class="user-mention" data-user-id="127859">@Taylor Cramer</span> pointed out</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>